package com.jsmtr.rms.service.impl;

import java.io.InputStream;
import java.sql.Blob;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.jsmtr.rms.entity.*;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.springframework.stereotype.Service;

import com.jsmtr.rms.dao.DaoService;
import com.jsmtr.rms.service.IDoMSService;
import com.jsmtr.rms.utils.EnumTools;
import com.jsmtr.rms.utils.db.DbUtil;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

@Service
@Transactional
public class DoMSService implements IDoMSService {

    @Resource
    private DaoService dao;

    public void setDao(DaoService dao) {
        this.dao = dao;
    }

    @Override
    public DoMSUser getMsUser(String fid, String uid) throws Exception {
        return (DoMSUser) dao.findUnique("from DoMSUser where fid='" + fid + "' and userid='" + uid + "'");
    }

    @Override
    public DoSSUser getSsUser(String fid, String uid) throws Exception {
        return (DoSSUser) dao.findUnique("from DoSSUser where fid='" + fid + "' and userid='" + uid + "'");
    }

    @Override
    public DoMSUser getMsUserByCardNo(String fid, String cardNo) throws Exception {
         return (DoMSUser) dao.findUnique(" from DoMSUser  where fid='"+fid+"' and userid=(select id from DUserResume  where  cardno='" + cardNo + "' and fid='"+fid+"')");
    }

    @Override
    public DoMSUser getMsUser(String id) throws Exception {
        return (DoMSUser) dao.findUnique("from DoMSUser where id='" + id + "'");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DoMSUser> getMsUsers(String[] uids, String fid) throws Exception {
        return dao.find("from DoMSUser where fid='" + fid + "' and userid in(:idlist)", uids);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Object[]> getMsUser(String[] uids, String fid, int recruittype) throws Exception {
       /* if (recruittype == EnumTools.RecruitType.内部招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.starttime,u.address,u.notice ");
            sql.append("from DNZResume r inner join DoMS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }*/
        if (recruittype == EnumTools.RecruitType.社会招聘.ordinal() || recruittype == EnumTools.RecruitType.高校校园招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.starttime,u.address,u.notice,c.isconfirm ");
            sql.append("from DUserResume r inner join DoMS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            sql.append(" inner join DoMS_Confirm c on u.id=c.msuserid ");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }
        if (recruittype == EnumTools.RecruitType.中专校园招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.starttime,u.address,u.notice,'否' ");
            sql.append("from hr_zzuser r inner join DoMS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }
        return null;
    }

    @Override
    public List<Object[]> getMsUser(String[] uids, String fid, ProjectInfo projectInfo) throws Exception {
        if (projectInfo.getId().indexOf("D_")>=0) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.starttime,u.address,u.notice ");
            sql.append("from DNZResume r inner join DoMS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }else if (projectInfo.getId().indexOf("C_")>=0) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.starttime,u.address,u.notice,'否' ");
            sql.append("from hr_zzuser r inner join DoMS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }else{
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.starttime,u.address,u.notice,c.isconfirm ");
            sql.append("from DUserResume r inner join DoMS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            sql.append(" inner join DoMS_Confirm c on u.id=c.msuserid ");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }

        //return null;
    }

    @Override
    public List<Object[]> getSsUser(String[] uids, String fid, ProjectInfo projectInfo) throws Exception {
        if (projectInfo.getId().indexOf("D_")>=0) {//内部
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.notice ");
            sql.append("from DNZResume r inner join DoSS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }else if ((projectInfo.getId().indexOf("C_")>=0)||(projectInfo.getId().indexOf("E_")>=0)) {//中专
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.notice ");
            sql.append("from hr_zzuser r inner join DoSS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }else{
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.tel,u.notice ");
            sql.append("from DUserResume r inner join DoSS_User u on r.id=u.userid and u.fid='" + fid + "' and r.id in(:idlist)");
           // sql.append(" inner join DoMS_Confirm c on u.id=c.msuserid ");
            System.out.println(sql.toString());
            return dao.findSql(sql.toString(), uids);
        }

        //return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Object[]> getMsUser(String fid, int recruittype) throws Exception {
       /* if (recruittype == EnumTools.RecruitType.内部招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append(" select u.id,r.name,r.sex,r.code,r.jname,'' as ecode,'' as ename,u.code ucode,u.uname uname ");
            sql.append(" from DNZResume r inner join (select mu.id,mu.userid,me.code,me.uname from DoMS_User mu left join DoMS_Examiner me on me.gid=mu.gid where mu.fid='" + fid + "') u on r.id=u.userid ");
            return dao.findSql(sql.toString());
        }*/
        if (recruittype == EnumTools.RecruitType.社会招聘.ordinal() || recruittype == EnumTools.RecruitType.高校校园招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append(" select  u.id,r.name,r.sexname,r.cardno,r.jname,'' as ecode,'' as ename,u.code ucode,u.uname uname ");
            sql.append(" from DUserResume r inner join (select mu.id,mu.userid,me.code,me.uname from DoMS_User mu left join DoMS_Examiner me on me.gid=mu.gid where mu.fid='" + fid + "') u on r.id=u.userid and r.nrid is null ");
            return dao.findSql(sql.toString());
        }
        if (recruittype == EnumTools.RecruitType.中专校园招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append(" select u.id,r.name,r.gender,r.code,'-' as jname,'' as ecode,'' as ename,u.code cardno,u.uname ");
            sql.append(" from hr_zzuser r inner join (select mu.id,mu.userid,me.code,me.uname from DoMS_User mu left join DoMS_Examiner me on me.gid=mu.gid where mu.fid='" + fid + "') u on r.id=u.userid ");
            return dao.findSql(sql.toString());
        }
        return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Object[]> getMsUserNoExaminer(String fid, int recruittype) throws Exception {
        /*if (recruittype == EnumTools.RecruitType.内部招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.sex,r.code,r.jname,'' as ecode,'' as ename ");
            sql.append("from DNZResume r inner join (select mu.id,mu.userid from DoMS_User mu  where mu.fid='" + fid + "') u on r.id=u.userid");
            return dao.findSql(sql.toString());
        }*/
        if (recruittype == EnumTools.RecruitType.社会招聘.ordinal() || recruittype == EnumTools.RecruitType.高校校园招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append("select  u.id,r.name,r.sexname,r.cardno,r.jname,u.point,u.result,u.scoringrules ");
            sql.append("from DUserResume r inner join (select mu.id,mu.userid,mu.point,mu.result,mu.scoringrules from DoMS_User mu  where mu.fid='" + fid + "') u on r.id=u.userid and r.nrid is null");
            return dao.findSql(sql.toString());
        }
        if (recruittype == EnumTools.RecruitType.中专校园招聘.ordinal()) {
            StringBuilder sql = new StringBuilder();
            sql.append("select u.id,r.name,r.gender,r.code,r.job,u.point,u.result,u.scoringrules ");
            sql.append("from hr_zzuser r inner join (select mu.id,mu.userid,mu.point,mu.result,mu.scoringrules from DoMS_User mu  where mu.fid='" + fid + "') u on r.id=u.userid");
            return dao.findSql(sql.toString());
        }
        return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DoMSEvaluation> getMSEvaluations(String gid) throws Exception {
        return dao.find("from DoMSEvaluation where gid='" + gid + "'");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DoMSExaminer> getMSExaminers(String gid) throws Exception {
        return dao.find("from DoMSExaminer where gid='" + gid + "'");
    }

    @Override
    public Map<String, Object> getSZPointUsers(int page, int perpage, String fid) throws Exception {
        StringBuffer queryHQL = new StringBuffer("select r.id,u.id as msuid,r.code,r.name,");
        queryHQL.append("r.educationname,r.workexperience,r.tel,u.starttime,u.address,r.fqstate,u.pointuser,r.fid,u.num ");
        StringBuffer countHQL = new StringBuffer("select count(1) ");
        StringBuffer condition = new StringBuffer("from DUserResume r inner join DoMS_User u on u.userid=r.id and u.fid='" + fid + "' and u.notice='" + EnumTools.NoticeState.已发通知.ordinal() + "' order by to_number(u.num)");
        queryHQL.append(condition);
        countHQL.append(condition);

        return DbUtil.pageSqlQuery(page, perpage, queryHQL.toString(), countHQL.toString(), dao);
    }

    @Override
    public Map<String, Object> getGXPointUsers(int page, int perpage, String fid) throws Exception {
        StringBuffer queryHQL = new StringBuffer("select u.num,r.university,r.majorname,r.educationname,u.starttime,u.address,");
        queryHQL.append("u.id,r.fqstate,u.pointuser,r.fid ");
        StringBuffer countHQL = new StringBuffer("select count(1) ");
        StringBuffer condition = new StringBuffer("from DUserResume r inner join DoMS_User u on u.userid=r.id and u.fid='" + fid + "' and u.notice='" + EnumTools.NoticeState.已发通知.ordinal() + "' order by to_number(u.num)");
        queryHQL.append(condition);
        countHQL.append(condition);

        return DbUtil.pageSqlQuery(page, perpage, queryHQL.toString(), countHQL.toString(), dao);
    }

    @Override
    public Map<String, Object> getNZPointUsers(int page, int perpage, String fid) throws Exception {
        StringBuffer queryHQL = new StringBuffer("select r.id,u.id as msuid,r.code,r.name,r.sex,r.age,r.zzmm,");
        queryHQL.append("r.groupdate,r.education,r.tel,u.starttime,u.address,r.fqstate,u.pointuser,u.num ");
        StringBuffer countHQL = new StringBuffer("select count(1) ");
        StringBuffer condition = new StringBuffer("from DNZResume r inner join DoMS_User u on u.userid=r.id and u.fid='" + fid + "' and u.notice='" + EnumTools.NoticeState.已发通知.ordinal() + "' order by to_number(u.num)");
        queryHQL.append(condition);
        countHQL.append(condition);

        return DbUtil.pageSqlQuery(page, perpage, queryHQL.toString(), countHQL.toString(), dao);
    }

    @Override
    public Map<String, Object> getZZPointUsers(int page, int perpage, String fid) throws Exception {
        StringBuffer queryHQL = new StringBuffer("select r.id,u.id as msuid,r.name,r.gender,r.code,r.major,");
        queryHQL.append("r.deptname,u.starttime,u.address,r.fqstate,u.pointuser,u.num ");
        StringBuffer countHQL = new StringBuffer("select count(1) ");
        StringBuffer condition = new StringBuffer("from HR_ZZUser r inner join DoMS_User u on u.userid=r.id and u.fid='" + fid + "' and u.notice='" + EnumTools.NoticeState.已发通知.ordinal() + "' order by to_number(u.num)");
        queryHQL.append(condition);
        countHQL.append(condition);

        return DbUtil.pageSqlQuery(page, perpage, queryHQL.toString(), countHQL.toString(), dao);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ProjectInfoFlow> getFlows(String pid, int ftype) throws Exception {
        return dao.find(" from ProjectInfoFlow where pid='" + pid + "' and fid='" + ftype + "'");
    }

    @Override
    public ProjectInfo getProjectByFid(String fid) throws Exception {
        return (ProjectInfo) dao.findUnique("from ProjectInfo where id=(select pid from ProjectInfoFlow where id='" + fid + "')");
    }

    @Override
    public DoMSResult getMsResult(String msuid, String code) throws Exception {
        return (DoMSResult) dao.findUnique("from DoMSResult where msuid='" + msuid + "' and code='" + code + "' ");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DoMSResultDetail> getMSResultDetail(String msrid) throws Exception {
        return dao.find("from DoMSResultDetail where msrid='" + msrid + "'");
    }

    @Override
    public DoMSExaminer getExaminer(String gid, String ucode) throws Exception {
        return (DoMSExaminer) dao.findUnique("from DoMSExaminer where gid='" + gid + "' and code='" + ucode + "'");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DoMSResult> getMsResultNoMe(String msuid, String code) throws Exception {
        return dao.find("from DoMSResult where msuid='" + msuid + "' and code!='" + code + "' ");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DoMSResult> getMsResults(String msuid) throws Exception {
        return dao.find("from DoMSResult where msuid='" + msuid + "' ");
    }

    @Override
    public int getMsCount(String fid) throws Exception {
        String sql = "select count(1) from DoMSUser where fid ='" + fid + "'";
        return ((Long) dao.findUnique(sql)).intValue();
    }

    @Override
    public int getSsCount(String fid) throws Exception {
        String sql = "select count(1) from DoSSUser where fid ='" + fid + "'";
        return ((Long) dao.findUnique(sql)).intValue();
    }

    @Override
    public Map<String, Object> queryMsBatch(int page, int perpage, String mspch, String pname, String recruittype, String jname, String msaddress, String msstarttime, String cardno, String name,String filename) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        String sql =" select mspc.mspch,\n" +
                "       mspc.pid,\n" +
                "       mspc.pname,\n" +
                "       mspc.recruittype,\n" +
                "       mspc.jname,\n" +
                "       mspc.jid,\n" +
                "       mspc.address,\n" +
                "       mspc.starttime,\n" +
                "       max(mspcrs) mspcrs,\n" +
                "       count(eu.id) msfjgs\n" +
                "  from (select t.address || '[' ||\n" +
                "               to_char(to_date(t.starttime, 'yyyy-MM-dd hh24:MI'),\n" +
                "                       'yyyyMMddHHMI') || ']' mspch,\n" +
                "               pi.id pid,\n" +
                "               pi.pname,\n" +
                "               pi.recruittype,\n" +
                "               du.jname,\n" +
                "               du.jid,\n" +
                "               t.address,\n" +
                "               t.starttime,\n" +
                "               count(t.userid) mspcrs\n" +
                "          from DOMS_USER         t,\n" +
                "               Duserresume       du,\n" +
                "               Project_Info      pi,\n" +
                "               project_info_flow pf\n" +
                "         where t.userid = du.id\n" +
                "           and pi.id = pf.pid\n" +
                "           and pf.id = t.fid\n" ;
                if(cardno!=null&&cardno.trim().length()>0){
                 sql+=   "           and du.cardno = "+cardno+"\n" ;
                }

                if(name!=null&&name.trim().length()>0){
                sql+= "           and du.name  like '%"+name+"%' \n" ;
                }
        sql+="         group by t.address || '[' ||to_char(to_date(t.starttime, 'yyyy-MM-dd hh24:MI'),'yyyyMMddHHMI') || ']',\n" +
                "                  pi.id,\n" +
                "                  pi.pname,\n" +
                "                  pi.recruittype,\n" +
                "                  du.jname,\n" +
                "                  du.jid,\n" +
                "                  t.address,\n" +
                "                  t.starttime) mspc,\n" +
                "       DOMS_ENCLOSURE eu\n" +
                " where mspc.mspch = eu.mspch(+)\n" ;
                if(filename!=null&&filename.trim().length()>0){
                    sql+=" and eu.filename like '%"+filename+"%' \n";
                }
                if(jname!=null&&jname.trim().length()>0){
                    sql+=" and mspc.jname like '%"+jname+"%' \n";
                }
                if(mspch!=null&&mspch.trim().length()>0){
                    sql+=" and mspc.mspch like '%"+mspch+"%' \n";
                }
                if(pname!=null&&pname.trim().length()>0){
                    sql+=" and mspc.pname like '%"+pname+"%' \n";
                }
                if(msaddress!=null&&msaddress.trim().length()>0){
                    sql+=" and mspc.address like '%"+msaddress+"%' \n";
                }
                if(msstarttime!=null&&msstarttime.trim().length()>0){
                    sql+=" and mspc.starttime like '%"+msstarttime+"%' \n";
                }
                if(recruittype!=null&&recruittype.trim().length()>0){
                    sql+=" and mspc.recruittype ="+recruittype+" \n";
                }
                sql+=" group by mspc.mspch,\n" +
                "          mspc.pid,\n" +
                "          mspc.pname,\n" +
                "          mspc.recruittype,\n" +
                "          mspc.jname,\n" +
                "          mspc.jid,\n" +
                "          mspc.address,\n" +
                "          mspc.starttime\n" +
                " order by mspc.starttime desc";
        StringBuffer countSQL=new StringBuffer("select count(1) from (");
        countSQL.append(sql+" )");
        double count = Double.parseDouble( dao.findUniqueSql(countSQL.toString()).toString());
        double pageCount = Math.ceil(count / (double) perpage);
        List list = dao.findLimitSql(sql, perpage * (page - 1), perpage);
        map.put("pageCount", pageCount);
        map.put("count", count);
        map.put("list", list);
        return map;

    }

    @Override
    public Map<String, Object> queryMsBatchUser(int page, int perpage, String mspch, String pname, String recruittype, String jname, String msaddress, String msstarttime, String cardno, String name,String filename) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        String sql =
                "select *\n" +
                        "  from (select mu.address || '[' ||\n" +
                        "               to_char(to_date(mu.starttime, 'yyyy-MM-dd hh24:MI'),\n" +
                        "                       'yyyyMMddHHMI') || ']' mspch,\n" +
                        "               du.name,\n" +
                        "               du.cardno,\n" +
                        "               du.tel,\n" +
                        "               du.university,\n" +
                        "               du.majorname,\n" +
                        "               du.educationname,\n" +
                        "               mu.address,\n" +
                        "               mu.starttime,\n" +
                        "               du.jname,\n" +
                        "               dc.isconfirm,\n" +
                        "               dc.confirmtime,\n" +
                        "               du.proname\n" +
                        "          from Doms_User mu, Duserresume du, Doms_Confirm dc\n" +
                        "         where mu.userid = du.id\n" +
                        "           and mu.id = dc.msuserid(+) order by  dc.confirmtime asc    ) temp where 1=1";
        if(cardno!=null&&cardno.trim().length()>0){
            sql+=   "           and temp.cardno = "+cardno+"\n" ;
        }

        if(name!=null&&name.trim().length()>0){
            sql+= "           and temp.name  like '%"+name+"%' \n" ;
        }

        if(jname!=null&&jname.trim().length()>0){
            sql+=" and temp.jname like '%"+jname+"%' \n";
        }
        if(mspch!=null&&mspch.trim().length()>0){
            sql+=" and temp.mspch like '%"+mspch+"%' \n";
        }
        if(pname!=null&&pname.trim().length()>0){
            sql+=" and temp.proname like '%"+pname+"%' \n";
        }
        if(msaddress!=null&&msaddress.trim().length()>0){
            sql+=" and temp.address like '%"+msaddress+"%' \n";
        }
        if(msstarttime!=null&&msstarttime.trim().length()>0){
            sql+=" and temp.starttime like '%"+msstarttime+"%' \n";
        }

        StringBuffer countSQL=new StringBuffer("select count(1) from (");
        countSQL.append(sql+" )");
        double count = Double.parseDouble( dao.findUniqueSql(countSQL.toString()).toString());
        double pageCount = Math.ceil(count / (double) perpage);
        List list = dao.findLimitSql(sql, perpage * (page - 1), perpage);
        map.put("pageCount", pageCount);
        map.put("count", count);
        map.put("list", list);
        return map;

    }

    @Override
    public Map<String, Object> queryMsBatchFile(int page, int perpage, String mspch, String pname, String recruittype, String jname, String msaddress, String msstarttime, String filename) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        String sql = "select t.id,t.filename,t.filesize,t.uploaduser,t.uploadtime,t.mspch,t.pid,t.pname,t.jid,t.jname  from DOMS_ENCLOSURE t where 1=1 ";

        if(filename!=null&&filename.trim().length()>0){
            sql+=" and t.filename like '%"+filename+"%' \n";
        }
        if(jname!=null&&jname.trim().length()>0){
            sql+=" and t.jname like '%"+jname+"%' \n";
        }
        if(mspch!=null&&mspch.trim().length()>0){
            sql+=" and t.mspch like '%"+mspch+"%' \n";
        }
        if(pname!=null&&pname.trim().length()>0){
            sql+=" and t.pname like '%"+pname+"%' \n";
        }
        if(msaddress!=null&&msaddress.trim().length()>0){
            sql+=" and t.msaddress like '%"+msaddress+"%' \n";
        }
        if(msstarttime!=null&&msstarttime.trim().length()>0){
            sql+=" and t.msstarttime like '%"+msstarttime+"%' \n";
        }

        sql+=" order by t.uploadtime desc";
        StringBuffer countSQL=new StringBuffer("select count(1) from (");
        countSQL.append(sql+" )");
        double count = Double.parseDouble( dao.findUniqueSql(countSQL.toString()).toString());
        double pageCount = Math.ceil(count / (double) perpage);
        List list = dao.findLimitSql(sql, perpage * (page - 1), perpage);
        map.put("pageCount", pageCount);
        map.put("count", count);
        map.put("list", list);
        return map;

    }

    @Override
    @Transactional
    public void UploadMsBacthFile(DoMsEnclosure enclosure) throws Exception {
        dao.add(enclosure);
    }

    @Override
    public DoMsEnclosure getMsBatchFile(String id) throws Exception {
       return  (DoMsEnclosure)dao.get(DoMsEnclosure.class,id);
    }

    @Override
    public List getMsTimse(String pid) throws Exception {

        return dao.executeSQLQuery(" select ms.starttime from Doms_User ms where ms.fid='" + pid + "' group by ms.starttime" );

    }

    @Override
    public List getMsAddresss(String pid) throws Exception {
        return dao.executeSQLQuery(" select ms.address from Doms_User ms where ms.fid='" + pid + "' group by ms.address" );

    }
}
